import request from '@/utils/request'
import { CHECC_API_CMS } from '@/constants/proxy'

/*
 * 机构管理模块
 */

// 保存
export const saveOrg = (data) => {
  return request({
    url: CHECC_API_CMS + '/org',
    method: 'post',
    data: data
  })
}

// 获取机构列表
export const getOrg = () => {
  return request({
    url: CHECC_API_CMS + '/org',
    method: 'get'
  })
}

//4A映射机构
export const get4AOrg = () => {
  return request({
    url: CHECC_API_CMS + '/org/getAAAAOrgTree',
    method: 'get',
  })
}
//根据id获取4A
export const get4AOrgData = (orgid) => {
  return request({
    url: CHECC_API_CMS + '/org/getAaaaDataByOrg',
    method: 'get',
    params:orgid
  })
}
//根据id获取领导
export const getUserById = (id) => {
  return request({
    url: CHECC_API_CMS + '/user/getUserById?id='+ id,
    method: 'get',
  })
}
// 获取机构树
export const getOrgTree = () => {
  return request({
    url: CHECC_API_CMS + '/org/tree',
    method: 'get'
  })
}
// 获取行政区域
export const getRegionOptions = (data) => {
  return request({
    url: CHECC_API_CMS + '/inner/region/regionTree',
    method: 'post',
    data
  })
}

// 更新机构
export const updateOrg = (data) => {
  return request({
    url: CHECC_API_CMS + '/org',
    method: 'put',
    data: data
  })
}
// 删除机构
export const deleteOrg = (id) => {
  return request({
    url: CHECC_API_CMS + '/org/' + id,
    method: 'delete'
  })
}
